<template>
  <div class="dashboard">
    <el-row class="heardRow" type="flex" justify="center">
      <!-- 总答题数量 -->
      <el-col>
        <el-card>
          <!-- 头部 -->
          <div class="header">
            <span>总答题数量</span>
            <i class="el-icon-warning"></i>
          </div>
          <!-- 内容 -->
          <div class="total">260,560</div>
          <div class="trends">
            <span
              >周同比 12%
              <i class="el-icon-caret-top icon-top"></i>
            </span>
            <span class="daySpan"
              >日环比 11%
              <i class="el-icon-caret-bottom icon-btn"></i>
            </span>
          </div>
          <div class="hr"></div>
          <!-- 底部 -->
          <div class="footer">
            <span>日答题数量</span>
            <span class="number">12,423</span>
          </div>
        </el-card>
      </el-col>
      <!-- 试题方向 -->
      <el-col>
        <el-card>
          <question-chart></question-chart>
        </el-card>
      </el-col>
      <!-- 试题学科分布 -->
      <el-col>
        <el-card>
          <subject-chart></subject-chart>

        </el-card>
      </el-col>
      <!-- 上周试题新增 -->
      <el-col>
        <el-card>
          <add-chart></add-chart>
        </el-card>
      </el-col>
    </el-row>
    <br />
    <el-row class="trendTest" type="flex" justify="center">
      <el-col>
        <el-card class="trend">
          <div class="text">前端与java学科试题走势图</div>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="前端学科" name="first"></el-tab-pane>
            <el-tab-pane label="JAVA学科" name="second"></el-tab-pane>
            <test-question :channel="testList"></test-question>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>

import questionChart from '@/views/dashboard/component/question-chart'
import subjectChart from '@/views/dashboard/component/subject-chart'
import addChart from '@/views/dashboard/component/add-chart'
import testQuestion from '@/views/dashboard/component/test-question'

export default {
  name: 'dashboard',
  components: {
    questionChart,
    subjectChart,
    addChart,
    testQuestion
  },
  data() {
    return {
      activeName: 'first',
      testList: [100, 120, 161, 134, 105, 160, 165, 100, 120, 161, 134, 105]
    }
  },
  created() {},
  mounted() {},
  methods: {
    handleClick() {
      if (this.activeName === 'first') {
        return (this.testList = [
          100,
          120,
          161,
          134,
          105,
          160,
          165,
          100,
          120,
          161,
          134,
          105
        ])
      } else {
        return (this.testList = [
          200,
          192,
          120,
          144,
          160,
          130,
          140,
          105,
          160,
          165,
          100,
          120
        ])
      }
    }
  }
}
</script>

<style lang="less" scoped>
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  .heardRow {
    flex: 1;
    margin: 0 -10px;

    .el-col {
      width: 25%;
      min-height: 230px;
      padding: 0 10px;
      .el-card {
        padding: 0 10px;
        /deep/.el-card__body {
          width: 100%;
          height: 245px;
          padding: 10px 20px;
          box-sizing: border-box;
          .header {
            height: 25px;
            color: #97a8be;
            font-size: 14px;
            i {
              float: right;
            }
          }
          .total {
            height: 140px;
            line-height: 140px;
            width: 100%;
            font-size: 40px;
            padding-left: 20px;
          }
          .trends {
            height: 22px;
            font-size: 16px;
            .icon-top {
              color: red;
            }
            .daySpan {
              margin-left: 20px;
              .icon-btn {
                color: green;
              }
            }
          }
          .hr {
            border-top: 1px solid #ccc;
            margin: 5px 0 10px 0;
          }
          .footer {
            height: 22px;
            line-height: 22px;
            font-size: 14px;
            .number {
              margin-left: 8px;
            }
          }
        }
      }
    }
  }
  .trendTest {
    flex: 1;
    .trend {
      position: relative;
      width: 100%;
      height: 100%;
      .text {
        position: absolute;
        right: 20px;
        top: 20px;
        color: rgb(153, 153, 153);
      }
    }
  }
  .buttom {
    height: 150px;
  }

}
</style>
